package com.ha.mapper;

import com.github.pagehelper.Page;
import com.ha.annotation.AutoFill;
import com.ha.dto.EmployeePageQueryDTO;
import com.ha.entity.Employee;
import com.ha.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

/**
 * ClassName: EmployeeMapper
 * Package: com.ha.mapper
 * Description:
 *
 * @Author 那啥啥
 * @Create 2024/3/31  17:12
 * @Version 1.0
 */
@Mapper
public interface EmployeeMapper {
    /**
     * 根据username查询用户
     * @param username
     * @return
     */
    @Select("select *from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 插入员工数据
     * @param employee
     */
    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into employee" +
            " (name , username , password,phone,sex,id_number,create_time,update_time,create_user,update_user,status) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime}," +
            "#{createUser},#{updateUser},#{status})")
    void insert(Employee employee);

    /**
     * 分页查询
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 根据主键动态哦更新
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Employee employee);

    /**
     * 根据id查寻员工
     * @param id
     * @return
     */
    @Select("select  *from employee where  id = #{id}")
    Employee getById(Long id);
}
